//package de.tum.activities.ExamEvaluation;
//
//import java.io.File;
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.util.ArrayList;
//import java.util.Date;
//import java.text.SimpleDateFormat;
//
//import de.tum.ExamApp.R;
//import de.tum.activities.Help.ImageAdapter;
//import android.app.Activity;
//import android.content.Intent;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.net.Uri;
//import android.os.Bundle;
//import android.os.Environment;
//import android.provider.MediaStore;
//import android.util.Log;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.Button;
//import android.widget.EditText;
//import android.widget.GridView;
//import android.widget.ImageView;
//import android.widget.Toast;
//
//public class CopyOfExamEvaluationActivity extends Activity{
//	
//	private static int cameraIntentRequestCode = 100;
//	
//	private EditText editTextStudentName, editTextMatrNr;
//	private Button evaluateButton;
//	private GridView gridView;
//	
//	private ImageAdapter imageAdapter;
//	
//	private Uri fileUri;
//	private Bitmap curImageBitmap;
//	
//	
//	private String studentsName, matrNr;
//	
//    /** Called when the activity is first created. */
//    @Override
//    public void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.evaluateapp);
//
//        editTextStudentName = (EditText) findViewById(R.id.evaluate_studentsName);
//        editTextMatrNr = (EditText) findViewById(R.id.evaluate_studentsMatrNr);
//        
//        evaluateButton = (Button) findViewById(R.id.evaluateButton);
//        evaluateButton.setOnClickListener(new OnClickListener() {
//			
//			public void onClick(View v) {
//				evaluateExam();
//			}
//
//		});
//        
//        imageAdapter = new ImageAdapter(this, R.id.gridView1, new ArrayList<Bitmap>());
//        
//        gridView = (GridView) findViewById(R.id.gridView1);
//        gridView.setAdapter(imageAdapter);
//    }
//    
//    private void evaluateExam() {
//    	studentsName = editTextStudentName.getText().toString();
//    	matrNr = editTextMatrNr.getText().toString();
//    	
//    	studentsName = studentsName.trim();
//    	matrNr = matrNr.trim();
//    	 
//    	if(matrNr.isEmpty() || studentsName.isEmpty()){
//    		Toast.makeText(this, getString(R.string.insertNameAndMatrNr), Toast.LENGTH_SHORT).show();
//    		return;
//    	}
//    	
//    	Log.d("MyCameraApp", "started");
//        
//    	useCamera();
//       
//	}
//    
//    private void useCamera(){
//    	// create Intent to take a picture and return control to the calling application
//        
//        
//        fileUri = getOutputMediaFileUri(); // create a file to save the image
//        
//        Log.d("File-Uri!!!", fileUri.toString());
//        
//        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//        setResult(Activity.RESULT_OK, intent);
//        
//        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
//        
//        startActivityForResult(intent, cameraIntentRequestCode);
//    }
//    
//    
//    public static final int MEDIA_TYPE_IMAGE = 1;
//
//    /** Create a file Uri for saving an image or video */
//    private static Uri getOutputMediaFileUri(){
//          return Uri.fromFile(getOutputMediaFile());
//    }
//
//    /** Create a File for saving an image or video */
//    private static File getOutputMediaFile(){
//        // To be safe, you should check that the SDCard is mounted
//        // using Environment.getExternalStorageState() before doing this.
//    	
//        File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
//                  Environment.DIRECTORY_PICTURES), "KlausurEvaluations");
//        // This location works best if you want the created images to be shared
//        // between applications and persist after your app has been uninstalled.
//
//        // Create the storage directory if it does not exist
//        if (! mediaStorageDir.exists()){
//            if (! mediaStorageDir.mkdirs()){
//                Log.d("MyCameraApp", "failed to create directory");
//                return null;
//            }
//        }else{
//            Log.d("MyCameraApp", "directory exists");
//        }
//
//        // Create a media file name
//        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
//        File mediaFile = new File(mediaStorageDir.getPath() + File.separator +
//            "IMG_"+ timeStamp + ".jpg");
//        return mediaFile;
//    }
//    
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data){
//    	super.onActivityResult(requestCode, resultCode, data);
//
//		Log.d("JUHU", "resultCode: " + resultCode  + "requestCode: " + requestCode);
//		if(resultCode != RESULT_CANCELED){
//
//	    	if(requestCode == cameraIntentRequestCode){
//
//	    		if(fileUri == null)
//	    			return;
//	    		
//	        	File imageFile = new File(fileUri.getPath());
//	            
//	            if(imageFile.exists()){
//	            	BitmapFactory.Options options = new BitmapFactory.Options();
//	            	options.outWidth =  296;
//	            	options.outHeight = 421;
//	            	Bitmap image = BitmapFactory.decodeFile(imageFile.getAbsolutePath(), options);
//	            	imageAdapter.add(image);
//	            	Log.d("MyCameraApp", "ImageAdapter-Size: "+ imageAdapter.getCount());
//	            }else{
//	            	Log.d("MyCameraApp", "IMAGEFILE NOT EXISTING");
//	            }
//	    	}
//		}
//    	
//    }
//
//}
